package com.smbms.service.impl;

import com.smbms.mapper.BillMapper;
import com.smbms.pojo.Bill;

import com.smbms.service.BIllService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;
@Service
public class BillServiceImpl implements BIllService {
    @Autowired
    private BillMapper billMapper;



//查所有
    public List<Bill> showAll() throws SQLException {

        return billMapper.findAll();
    }
//删除
    public boolean del(Long id) throws Exception {
        int isOK = billMapper.del(id);
        if (isOK > 0) {
            return true;
        }
        return false;
    }
    //增加
    public boolean addBill(Bill bill) throws Exception {

        int row = billMapper.insert(bill);
        if (row>0){
            return true;
        }
        return false;
    }


//修改
    public boolean updateBill(Bill bill) throws Exception {
        int row = billMapper.updateById(bill);
        if(row>0){
            return true;
        }
        return false;
    }
//根据id查找账单
    public Bill showBillById(long id) throws Exception {
        Bill bill1 = billMapper.findById(id);
        return bill1;
    }
}
